package cn.com.ctcloud.saas.ids.demo.user.domain;

import java.io.Serializable;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.Range;

/**
 * Title: ChinaCT IDS
 * <p>
 * Description: Demo
 * <p>
 * Copyright: Copyright (c) 2008
 * <p>
 * Company: Liaoning Open Data Communication Co.,Ltd.
 *
 * @author lihui
 * @version 2.0.0
 */
public class UserDemoObj implements Serializable {
	public static final String TABLE_NAME = "T_USER";
	public static final String TABLE_ID = "ID";
	public static final String TABLE_LOGIC_ID = "LOGIC_ID";
	private static final long serialVersionUID = -15404526914910L;
	// 主键
	private String id;
	// 逻辑主键
	private String logicId;
	// 登录名
	@NotBlank(message = "登录名不能为空")
	private String name;
	// 登录密码
	@NotNull
	@Size(min = 5, max = 10, message = "密码必须在5-10位之间")
	private String pwd;
	// 年龄
	@Range(min = 0, max = 120, message = "年龄不能为负数并且不能超过120岁")
	private Integer age;
	// 邮箱
	@Pattern(regexp = "^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$", message = "需要输入正确格式的邮箱")
	private String email;

	/**
	 * 得到对象的哈希值
	 *
	 * @return int 对象的哈希值
	 */
	public int hashCode() {
		return new HashCodeBuilder().append(this.getLogicId()).toHashCode();
	}

	/**
	 * 比较两个对象是否相等
	 *
	 * @param other
	 *            要比较的对象
	 * @return boolean 相同返回true，否则返回flase
	 */
	public boolean equals(final Object other) {
		if (!(other instanceof UserDemoObj)) {
			return false;
		}
		final UserDemoObj castOther = (UserDemoObj) other;
		return new EqualsBuilder().append(this.getLogicId(), castOther.getLogicId()).isEquals();
	}

	/**
	 * 返回对象的字符串值
	 *
	 * @return String 表示用户对象的字符串值
	 */
	public String toString() {
		return new ToStringBuilder(this).append("", this.getLogicId()).toString();
	}

	public String getId() {
		return id;
	}

	public void setId(final String id) {
		this.id = id;
	}

	public String getLogicId() {
		return logicId;
	}

	public void setLogicId(final String logicId) {
		this.logicId = logicId;
	}

	public String getName() {
		return name;
	}

	public void setName(final String name) {
		this.name = name;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(final String pwd) {
		this.pwd = pwd;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}
}